import 'package:appflutter/day14_theme/size_fit.dart';

import 'theme_data.dart';
import 'package:flutter/material.dart';
import 'extension/double_extension.dart';
import 'extension/int_extension.dart';

main() => runApp(myApp());

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    size_fit.initialize();

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: theme_data.lightTheme,
      darkTheme: theme_data.darkTheme,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {

    print('${size_fit.screenWidth}*${size_fit.screenHeight},${size_fit.statusHeight},${size_fit.tabbarHeight}');

    return Scaffold(
      appBar: AppBar(
        title: Text('首页'),
        elevation: 0,
      ),
      body: Center(
          child: Column(
        children: <Widget>[
          Text('hello world'),
          Card(
            child: Text('hello world'),
          ),
          RaisedButton(
            onPressed: () {},
            child: Text('r'),
          ),
          Container(

            child: Text('hello world',textAlign: TextAlign.center,),
            color: Colors.pinkAccent,
            width: 200.Pt,
            height: 200.0.Rpx,
          ),
        ],
      )),
      floatingActionButton: Theme(
        data: Theme.of(context).copyWith(
            colorScheme: Theme.of(context)
                .colorScheme
                .copyWith(secondary: Colors.pinkAccent)),
        child: FloatingActionButton(
          onPressed: () {
            Navigator.of(context)
                .push(MaterialPageRoute(builder: (ctx) => detail_page()));
          },
          child: Icon(Icons.pets),
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(items: [
        BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('首页')),
        BottomNavigationBarItem(icon: Icon(Icons.category), title: Text('分类'))
      ]),
    );
  }
}

class detail_page extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Theme(
      data: Theme.of(context).copyWith(primaryColor: Colors.amber),
      child: Scaffold(
        appBar: AppBar(
          title: Text('详情页'),
        ),
      ),
    );
  }
}
